package com.ccys.app.controller;

import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.dto.app.medicationsSelectScreen.GetPharmaciesDto;
import com.ccys.db.mapper.TblSupplierMapper;
import com.ccys.db.vo.app.medicationsSelectScreen.GetPharmaciesVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author：XLY
 * @Date：2024/1/26 0026
 */

@RestController
@RequestMapping("/medicationsSelectScreen")
@Api(tags = "Medications Select screen")
public class MedicationsSelectScreenController {

    @Resource
    private TblSupplierMapper mapper;


    @ApiOperation("Medications Select screen/ 2")
    @GetMapping("GetPhamacies")
    public ResponseResultApp getPharmacies(GetPharmaciesDto dto) {
        List<GetPharmaciesVo.PharmacyVo> pharmacies = mapper.getPharmacies(dto);
        GetPharmaciesVo vo = new GetPharmaciesVo();
        pharmacies.forEach(x -> {
            if (x.getType() == 1) {
                vo.getWhitecoat().add(x);
            } else {
                vo.getExternal().add(x);
            }
        });

        return ResponseResultApp.success(vo);
    }

    @ApiOperation("Medications Select screen/ 3")
    @GetMapping("CalculationCost")
    public ResponseResultApp calculationCost() {


        return ResponseResultApp.success();
    }

}
